Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@codemirror/lang-wast
Advanced tools
WebAssembly Text Format support for the CodeMirror code editor
@codemirror/lang-wast is a language support package for CodeMirror that provides syntax highlighting and other editor features for WebAssembly Text format (WAT). It is part of the CodeMirror 6 ecosystem, which is a versatile text editor implemented in JavaScript for the browser.
Syntax Highlighting
This code sets up a CodeMirror editor with syntax highlighting for WebAssembly Text format (WAT). The `wast` function from `@codemirror/lang-wast` is used to provide the necessary language support.
import { wast } from '@codemirror/lang-wast';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: `(module
(func (export "add") (param i32 i32) (result i32)
local.get 0
local.get 1
i32.add))`,
extensions: [basicSetup, wast()]
});
const view = new EditorView({
state,
parent: document.body
});
Code Folding
This code demonstrates how to add code folding to a CodeMirror editor with WebAssembly Text format (WAT) support. The `foldGutter` extension is used alongside `@codemirror/lang-wast`.
import { wast } from '@codemirror/lang-wast';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';
import { foldGutter } from '@codemirror/fold';
const state = EditorState.create({
doc: `(module
(func (export "add") (param i32 i32) (result i32)
local.get 0
local.get 1
i32.add))`,
extensions: [basicSetup, wast(), foldGutter()]
});
const view = new EditorView({
state,
parent: document.body
});
Linting
This code adds custom linting to a CodeMirror editor with WebAssembly Text format (WAT) support. The `linter` function is used to create a custom linter that can be integrated with `@codemirror/lang-wast`.
import { wast } from '@codemirror/lang-wast';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';
import { linter } from '@codemirror/lint';
const myWastLinter = linter(view => {
let diagnostics = [];
// Custom linting logic here
return diagnostics;
});
const state = EditorState.create({
doc: `(module
(func (export "add") (param i32 i32) (result i32)
local.get 0
local.get 1
i32.add))`,
extensions: [basicSetup, wast(), myWastLinter]
});
const view = new EditorView({
state,
parent: document.body
});
@codemirror/lang-javascript provides language support for JavaScript in CodeMirror. It offers similar features like syntax highlighting, code folding, and linting, but for JavaScript code instead of WebAssembly Text format.
@codemirror/lang-python offers language support for Python in CodeMirror. Like @codemirror/lang-wast, it provides syntax highlighting, code folding, and linting, but is tailored for Python code.
@codemirror/lang-html provides language support for HTML in CodeMirror. It includes features such as syntax highlighting, code folding, and linting, similar to @codemirror/lang-wast, but for HTML.
[ WEBSITE | ISSUES | FORUM | CHANGELOG ]
This package implements WebAssembly Text Format language support for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.
6.0.2 (2023-12-28)
Tag comments and strings as isolating for the purpose of bidirectional text.
FAQs
WebAssembly Text Format support for the CodeMirror code editor
The npm package @codemirror/lang-wast receives a total of 146,393 weekly downloads. As such, @codemirror/lang-wast popularity was classified as popular.
We found that @codemirror/lang-wast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.